package me.helllp.bootman.common.base;

import com.alibaba.fastjson.JSON;


/**
 * 统一API响应结果封装
 * 
 * @author 虎头
 *
 */
public class BaseReturn {
	/**
	 * 错误码
	 */
    private int code;
    
    /**
     * 错误信息
     */
    private String message = "";
    
    /**
     * 返回的数据
     */
    private Object data;

    /**
     * 返回的数据类型
     */
    private String type = "";
    
    public BaseReturn(){
    	
    }
    
    public BaseReturn(int code, String msg, Object data){
    	this.code = code;
    	this.message = msg;
    	this.data = data;
    	
    	if(this.data != null){
    		this.type = data.getClass().getName();
    	}
    }
    
	@Override
    public String toString() {
        return JSON.toJSONString(this);
    }

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
}
